package com.service.impl;

import com.bean.Power;
import com.bean.Role;
import com.dao.PowerDao;
import com.dao.impl.PowerDaoImpl;
import com.service.PowerService;

import java.util.ArrayList;
import java.util.List;

public class PowerServiceImpl implements PowerService {
    private PowerDao powerDao = new PowerDaoImpl();
    @Override
    public List<Power> getAllPower() {
        return powerDao.getAllPower();
    }

    @Override
    public List<Power> getPower(Role role) {
        return powerDao.getPower(role);
    }

    @Override
    public List<Power> getPower(String roleName) {
        return powerDao.getPower(roleName);
    }

    @Override
    public String[] getAllPowers() {
        List<Power> powerList =new ArrayList<>();
        powerList = powerDao.getAllPower();
        List<String> strings = new ArrayList<>();
        for (Power power:powerList) {
            String powerName = power.getPowerName();
            strings.add(powerName);
        }
        String[] strs =strings.toArray(new String[strings.size()]);
        return strs;
    }
}
